package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.CheckDeviceInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.SurveyDeviceInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ISurveyDeviceInfoConsumeService;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/surveyDevice" })
@Api("SurveyDeviceInfoController")
@CrossOrigin
public class SurveyDeviceInfoController {

	@Autowired 
	private ISurveyDeviceInfoConsumeService surveyDeviceInfoConsumeService;
	
	/**
     * 获取设备巡检对象信息；
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getSurveyDeviceInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=SurveyDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取监测对象信息")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String") })
	public ResultPojo getCheckDeviceInfo(
			@RequestParam(defaultValue = "",value="devId",required=false) String devId,
			HttpServletRequest request) {
		return surveyDeviceInfoConsumeService.getSurveyDeviceInfo(devId);
	}
	
	/**
     * 获取监测List集合；
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getSurveyDeviceInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=SurveyDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取监测List")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devIp", value = "诱导屏类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devFactory", value = "网络是否联通", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devDeptId", value = "部门编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "标签识别", paramType = "query", dataType = "String")})
	public ResultPojo getSurveyDeviceInfoList(
			@RequestParam(defaultValue = "",value="devId",required=false) String devId,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="devName",required=false) String devName,
			@RequestParam(defaultValue = "",value="devIp",required=false) String devIp,
			@RequestParam(defaultValue = "",value="devStatusCode",required=false) String devStatusCode,
			@RequestParam(defaultValue = "",value="devFactory",required=false) String devFactory,
			@RequestParam(defaultValue = "",value="devAreaCode",required=false) String devAreaCode,
			@RequestParam(defaultValue = "",value="devDeptId",required=false) String devDeptId,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,
			HttpServletRequest request) {
		return surveyDeviceInfoConsumeService.getSurveyDeviceInfoList(devId, devTypeCode, devName, devIp, devStatusCode, devFactory, devAreaCode,devDeptId,searchFlag);
	}

	/**
     * 获取巡检设备分页
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getSurveyDeviceInfoPage" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=SurveyDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检设备分页")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devIp", value = "设备IP", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devFactory", value = "设备厂家", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "标签识别", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devDeptId", value = "管理部门编号", paramType = "query", dataType = "String")})
	public ResultPojo getCheckDeviceInfoPage(
			@RequestParam(defaultValue = "",value="devId",required=false) String devId,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="devName",required=false) String devName,
			@RequestParam(defaultValue = "",value="devIp",required=false) String devIp,
			@RequestParam(defaultValue = "",value="devStatusCode",required=false) String devStatusCode,
			@RequestParam(defaultValue = "",value="devFactory",required=false) String devFactory,
			@RequestParam(defaultValue = "",value="devAreaCode",required=false) String devAreaCode,
			@RequestParam(defaultValue = "",value="devDeptId",required=false) String devDeptId,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,Page page,
			HttpServletRequest request) {
		return surveyDeviceInfoConsumeService.getSurveyDeviceInfoPage(devId, devTypeCode, devName, devIp, devStatusCode, devFactory, devAreaCode,devDeptId,searchFlag, page);
	}
	
	/**
     * 获取巡检数量
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getSurveyCount" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=SurveyDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检数量")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型", paramType = "query", dataType = "String")})
	public ResultPojo getSurveyCount(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return surveyDeviceInfoConsumeService.getSurveyCount(devTypeCode, beginTime, endTime);
	}
}
